Music Object Extension - Debug
|
|
This extension is designed to assist one in tracking down errors in sonification code. The features offered in this extension were built directly into the "music-object.js" file in Music Object versions earlier than 3.2.0. In the interest of reducing the size of the core Music Object API, these features were moved out of the core.
Since debugging and error catching are typically only useful when developing code, it is assumed they will not be needed once the sonified Web content is finalized and ready to go live. So, one can source in this extension during the development phase for the sonified content and then remove the links once the content is final and fully functional. Music Object versions 3.2.0 and higher still do basic error catching to help prevent users from seeing errors that may result from them interrupting the loading of sonified pages with JavaScript code, but one cannot customize ways of displaying error messages unless this extension is used.
For further information on debugging sonified content, consult the section Debugging Aids.
Browser Limitations
The Debug extension does not perform error handling for Microsoft Internet Explorer or Netscape 6, because of limitations in these browsers.
- Microsoft Internet Explorer
The Debug extension registers a handler for errors by setting the window.onerror property. The function that is registered as the error handler is called each time an error occurs. Unfortunately, however, Microsoft Internet Explorer does not support the window.onerror property. As a result, error handling cannot be performed by the Debug extension in Internet Explorer
- Netscape 6
With the initial release of Netscape 6, a problem was discovered that affects error handling. The Debug extension registers a handler for errors by setting the window.onerror property. The function that is registered as the error handler is called each time an error occurs, with parameters being passed to indicate the type of error that occurred, the file that it occurred in, and the specific line number where it occurred.
The bug with Netscape 6 results in useless information being passed to an error handler function, so this kind of error handling is of no value. What's more, if the Debug extension were to catch errors in Netscape 6, then these errors would not get reported to the browser's JavaScript console - one place where useful information is actually displayed. So, as a result of this bug, conditional logic exists within the Debug extension to prevent an error handler from being registered for Netscape 6. To debug code in Netscape 6, simply pop open the convenient JavaScript console.
|
What's New in the Latest Version
|
There is a dedicated version history for this extension, where you will be able to find out about the new features and possible issues with the most recent version. The version history for this extension is independent of the version history for the core Music Object API.
To get the "music-object-x-debug.js" JavaScript file that implements this extension, simply right-click on this link (click-and-hold for Mac users). Then, from the menu that pops up, select the 'Save Link As...' or 'Save Target As...' option and save the file as "music-object-x-debug.js" into an appropriate folder of the local copy of your Web site.
In case you have problems saving the file using the above link, the "music-object-x-debug.js" file can also be found inside the documentation's "javascript" folder, along with the "music-object.js" file.
In order to use this extension, the following JavaScript file(s) must first be sourced in...
- music-object.js (version 3.3.0 or higher)
For more information on using extensions, consult the section About Music Object Extensions.
The Music.debugMessage static method lets you send a message to the currently configured debug output.
|
Music.debugMessage ( DebugMessageSTR ) |
The Music.debugMessage method lets you send a message to the currently selected debug output (alert dialog, Java console, and window status bar). Debug output options are set using the static properties Music.debugToAlert, Music.debugToJavaConsole, and Music.debugToStatus.
In the following example, each time the function "refreshVolumeSlider" is called a message showing the volume update value will be displayed in the Java console. This kind of message is useful when trying to track down problems in the logic or order of execution of one's code.
<SCRIPT SRC="music-object.js"></SCRIPT>
<SCRIPT SRC="music-object-x-debug.js"></SCRIPT>
<SCRIPT LANGUAGE=JavaScript><!-- //
Music.debugToJavaConsole = true;
Music.debugToAlert = false;
Music.debugToStatus = true;
function updateVolumeSlider (newVolumeLevel) {
Music.debugMessage ('new value for slider = ' + newVolumeLevel);
// code to update the volume slider
}
// --></SCRIPT>
|
The Music.debugToAlert property is a boolean variable, specifying whether or not error messages are to be displayed in alert boxes. When set to false, errors will not be reported in alert boxes. And when set to true, errors will be reported in alert boxes.
For comprehensive guidelines on how to use this property in conjunction with the other debugging properties, see the section Music Object Debugging Aids.
The Music.debugToJavaConsole property is a boolean variable, specifying whether or not error messages are to be displayed in the Java console. When set to false, errors will not be reported in the Java console. And when set to true, errors will be reported in the Java console. Error messages can only be reported to the Java console when using Netscape Navigator, so this property will simply be ignored for Microsoft Internet Explorer and other browsers that do not provide a Java console.
For comprehensive guidelines on how to use this property in conjunction with the other debugging properties, see the section Music Object Debugging Aids.
The Music.debugToStatus property is a boolean variable, specifying whether or not error messages are to be displayed in the window's status bar. When set to false, errors will not be reported in the window's status bar. And when set to true, errors will be reported in the window's status bar.
For comprehensive guidelines on how to use this property in conjunction with the other debugging properties, see the section Music Object Debugging Aids.